package tezhongbing.socket;

import java.io.IOException;
import java.net.ServerSocket;

public class SocketServer2 {
	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = null;
		SocketWraper wraper = null;
		try {
			serverSocket = new ServerSocket(8888);
			System.out.println("端口8888已经打开，准备接受数据！");
			wraper = new SocketWraper(serverSocket.accept());
			String input = null;
			while(!"bye".equalsIgnoreCase(input=wraper.readLine())){
				System.out.println("客户端传来数据："+input);
				wraper.writeLine("我接收到你的数据："+input);
			}
			wraper.writeLine("close");
		}finally{
			if(serverSocket != null){
				serverSocket.close();
			}
		}
	}
}
